import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:mysql1/src/results/row.dart';

import 'base_model.dart';

///对应数据库 tbapplwarncfg 表
class WarnInfo{
  ///对应id
  int id;
  ///对应LWarnNumber
  int number;

  ///对应LWarnSName
  String sName;
  ///对应LWarnLName_EN
  String lNameEn;
  ///对应LWarnLName_CN
  String lNameCn;
  ///对应LWarnColor
  int color;
  ///对应LWarnPush
  int push;



  WarnInfo(this.id, this.number, this.sName, this.lNameEn, this.lNameCn,
      this.color, this.push);

  static WarnInfo builder(ResultRow row) {
    int id = row[0];
    int number=row[1];
    String sName = null==row[2] ? "":row[2].toString();
    String lNameEn = null==row[3] ? "":row[3].toString();
    String lNameCn = null==row[4] ? "":row[4].toString();
    int color = row[5];
    int push = row[6];
    return WarnInfo(id, number, sName, lNameEn, lNameCn, color, push);
  }

  Color getBgColor(){
    Color bgColor = Colors.white;
    if(color == 1){
      bgColor = Colors.red;
    }else if(color == 2){
      bgColor = Colors.yellow;
    }else if(color == 3){
      bgColor = Colors.green;
    }
    return bgColor;
  }

}